package evaluation;


/**
 * @author  user
 */
public class RecallPrecisionCurve {

	public static final int RECALL_LIST_SIZE = 11;
	public static final double[] RECALL_LIST 
		= {0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0};
	/**
	 * @uml.property  name="precisionList"
	 */
	private double[]  precisionList;
	
	public RecallPrecisionCurve(double[]  precisionList) {
		this.setPrecisionList(precisionList);
	}
	
	public RecallPrecisionCurve() {
		this.precisionList = new double [RECALL_LIST_SIZE];
	}

	public double getAveragePrecision() {
		double averagePrecision = 0.0;
		for (int i = 0; i < RECALL_LIST_SIZE; i++) {
			averagePrecision += precisionList[i]* 0.1;
		}
		return averagePrecision;
	}
	
	public void setPrecision(int recallLevel, double precision) {
		if (recallLevel < RECALL_LIST_SIZE -1 ) 
			precisionList[recallLevel] = precision;
	}
	
	/**
	 * @return  the precisionList
	 * @uml.property  name="precisionList"
	 */
	public double[] getPrecisionList() {
		return precisionList;
	}

	/**
	 * @param precisionList  must have RECALL_LIST_SIZE elements for basic values of recall
	 * @uml.property  name="precisionList"
	 */
	public void setPrecisionList(double[] precisionList) {
		if (precisionList.length == RECALL_LIST_SIZE) 
			this.precisionList = precisionList;
	}

}
